<template name="livechatCustomFieldForm">
	{{#requiresPermission 'view-livechat-customfields'}}
		<form id="customField-form" data-id="{{customField._id}}">
			<div class="rocket-form">
				{{#if Template.subscriptionsReady}}
					<fieldset>
						<div class="input-line">
							<label>{{_ "Field"}}</label>
							<div>
								<input type="text" class="rc-input__element custom-field-input" name="field" value="{{customField._id}}" readonly="{{$exists customField._id}}" placeholder="{{_ "Field"}}" />
							</div>
						</div>
						<div class="input-line">
							<label>{{_ "Label"}}</label>
							<div>
								<input type="text" class="rc-input__element custom-field-input" name="label" value="{{customField.label}}" placeholder="{{_ "Label"}}" />
							</div>
						</div>
						<div class="input-line">
							<label>{{_ "Scope"}}</label>
							<div>
								<select name="scope" class="rc-input__element custom-field-input">
									<option value="visitor" selected="{{$eq customField.scope 'visitor'}}">{{_ "Visitor"}}</option>
									<option value="room" selected="{{$eq customField.scope 'room'}}">{{_ "Room"}}</option>
								</select>
							</div>
						</div>
						<div class="input-line">
							<label>{{_ "Visibility"}}</label>
							<div>
								<select name="visibility" class="rc-input__element custom-field-input">
									<option value="visible" selected="{{$eq customField.visibility 'visible'}}">{{_ "Visible"}}</option>
									<option value="hidden" selected="{{$eq customField.visibility 'hidden'}}">{{_ "Hidden"}}</option>
								</select>
							</div>
						</div>
						<div class="input-line">
							<label>{{_ "Validation"}}</label>
							<div>
								<input type="text" class="rc-input__element custom-field-input" name="regexp" value="{{customField.regexp}}" placeholder="{{_ "Regexp_validation"}}" />
							</div>
						</div>
						{{#if customFieldsTemplate}}
							{{> Template.dynamic template=customFieldsTemplate data=dataContext }}
						{{/if}}
					</fieldset>
					<div class="rc-button__group submit">
						<button class="rc-button back" type="button"><i class="icon-left-big"></i><span>{{_ "Back"}}</span></button>
						<button class="rc-button rc-button--primary save"><i class="icon-floppy"></i><span>{{_ "Save"}}</span></button>
					</div>
				{{else}}
					{{> loading}}
				{{/if}}
			</div>
		</form>
	{{/requiresPermission}}
</template>
